﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace slwhTools.FileHelper
{
    public interface ISFileConfig
    {

        /// <summary>
        /// 最大文件限制 M
        /// </summary>
        public static long MaxFileSize = 100;

        /// <summary>
        /// 允许上传的文件格式 * 表示所有文件都可上传
        /// </summary>
        public static string[] AllowedExtensions = { "*" };

        /// <summary>
        /// 保存路径
        /// </summary>
        public static string SavePath = string.Empty;

        /// <summary>
        /// 默认保存目录
        /// </summary>
        public static string DefaultFileDicName = "SSaveFile";

        /// <summary>
        /// 文件扩展名流
        /// </summary>
        public static readonly Dictionary<string, byte[]> FileSignatures = new Dictionary<string, byte[]>
        {
            // 图片
            { ".jpg", new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 } },
            { ".jpeg", new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 } },
            { ".png", new byte[] { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A } },
            { ".gif", new byte[] { 0x47, 0x49, 0x46, 0x38 } }, // GIF8
            { ".bmp", new byte[] { 0x42, 0x4D } }, // BM
            { ".webp", new byte[] { 0x52, 0x49, 0x46, 0x46, 0x57, 0x45, 0x42, 0x50 } }, // RIFFWEBP
    
            // 文档
            { ".pdf", new byte[] { 0x25, 0x50, 0x44, 0x46 } }, // %PDF 
            { ".doc", new byte[] { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 } },
            { ".docx", new byte[] { 0x50, 0x4B, 0x03, 0x04 } }, // PK..
            { ".xls", new byte[] { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 } },
            { ".xlsx", new byte[] { 0x50, 0x4B, 0x03, 0x04 } }, // PK..
    
            // 压缩文件
            { ".zip", new byte[] { 0x50, 0x4B, 0x03, 0x04 } }, // PK..
            { ".rar", new byte[] { 0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00 } }, // Rar!...
            { ".7z", new byte[] { 0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C } }, // 7z¼¯'.
    
            // 音频视频
            { ".mp3", new byte[] { 0x49, 0x44, 0x33 } }, // ID3
            { ".wav", new byte[] { 0x52, 0x49, 0x46, 0x46, 0x57, 0x41, 0x56, 0x45 } }, // RIFFWAVE
            { ".mp4", new byte[] { 0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70 } }, // ....ftyp
    
            // 可执行文件
            { ".exe", new byte[] { 0x4D, 0x5A } }, // MZ
            { ".dll", new byte[] { 0x4D, 0x5A } } // MZ
        };

        /// <summary>
        /// 初始化信息
        /// </summary>
        public void Init();

    }
}
